// [user, info]
// 路由children属性嵌套路由 使用函数递归匹对接口放回的权限
export default function routesPermit (roles, routes) {
  const addRoutes = []
  routes.forEach(item => {
    if (item.path === '*' || item.meta.role.some(subItem => roles.includes(subItem))) {
      addRoutes.push(item)
    } else {
      return true
    }
    //  判断该路由对象有没有children属性
    if (item.children) {
      addRoutes[addRoutes.length - 1].children = routesPermit(roles, item.children)
    }
  })
  return addRoutes
}
